<?php
// Mobile WordPress 2 functions

function wpm2_show_navigation() {
	global $wp_query;
	return ( $wp_query->max_num_pages > 1 ) ? true : false;
}

function wpm2_body_class( $print = true ) {
	$c = array('mobile');
	is_front_page()  ? $c[] = 'home'        : null;
	is_home()        ? $c[] = 'blog'        : null;
	is_page()        ? $c[] = 'page'        : null;
	is_archive()     ? $c[] = 'archive'     : null;
	is_single()      ? $c[] = 'single'      : null;
	is_attachment()  ? $c[] = 'attachment'  : null;
	is_search()      ? $c[] = 'search'      : null;

	$c = join( ' ', apply_filters( 'body_class',  $c ) );
	return $print ? print($c) : $c;
}

function wpm2_xhtml_headers() {
	header('Vary: Accept');
	$charset  = get_bloginfo('charset');
	$language = 'en';
	$doctype  = '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">';
//	$doctype  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">';

	if ( strpos( strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml' ) ) {
		$mime = 'application/vnd.wap.xhtml+xml';
	} elseif ( strpos( strtolower($_SERVER['HTTP_ACCEPT']), 'application/xhtml+xml' ) ) {
		$mime = 'application/xhtml+xml';
	} else {
		$mime = 'text/html';
	}

	header("Cache-Control: Public");
	header("Pragma: Public");
	header("Expires: " . gmdate( "D, d M Y H:i:s", strtotime('+12 hours') ) . " GMT");
	header("Content-Type: $mime; charset=$charset");
	header("Content-Language: $language");
	print "<?xml version=\"1.0\" encoding=\"$charset\"?>\n$doctype\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$language\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"$mime; charset=$charset\" />\n<meta http-equiv=\"Content-Language\" content=\"$language\" />\n";
}


?>